<template>
	<!-- 表格数据 -->
	<InnerPageTable ref="listTable" :config="pageTableConfig" height="280" style="width: 100%;"></InnerPageTable>
</template>

<script>
	import {
		attachmentsColumns
	} from '../../js/quality-table'
	export default {
		props: {
			tableData: {
				type: Array,
				default: () => []
			},
			buName: {
				type: String,
				default: ""
			}
		},
		data() {
			return {
				pageTableConfig: {
					loadDataFn: this.getTableList,
					columns: attachmentsColumns.bind(this)(this.buName),
					autoFirst: false,
					border: true,
					isPage: false,
					initParam: {
						"buName": "",
						"bidFileRepRate": "",
						"quotationFileRepRate": ""
					},
					allSelection: []
				},
				tableList: []
			}
		},

		methods: {
			getTableList(tableObj) {
				const {
					responseProcess
				} = tableObj;
				if (this.tableList?.length && this.tableList?.length < 5) {
					const len = this.tableList.length;
					for (let i = len; i < 5; i++) {
						this.tableList.push({
							isEmpty:true,
							buName: "",
							bidFileRepRate: "",
							quotationFileRepRate: ""
						})
					}
				}
				const data = {
					records: this.tableList || []
				}
				responseProcess(data);
			},
		},
		watch: {
			tableData: {
				handler(newVal) {
					if (newVal?.length) {
						this.tableList = newVal;
						this.$refs.listTable.load();
					}
				},
				deep: true,
				immediate: true
			}
		}
	}
</script>
<style lang="less" scoped>
	.app-container {
		display: flex;
		justify-content: space-between;
	}
</style>